package com.jctrip.hotel.source.xxl.greentree.thread;

import com.jctrip.hotel.common.constant.RedisKeyConstant;
import com.jctrip.hotel.common.context.BeanContext;
import com.jctrip.hotel.common.util.RedisUtil;
import com.jctrip.hotel.source.service.atour.AtourTaskService;
import com.jctrip.hotel.source.service.greentree.GreenTreeTaskService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;

/**
 * @Author：Haruhi
 * @description:
 * @Date：2023/11/8 19:24
 * @Package：com.jctrip.hotel.source.xxl.greentree.thread
 * @Project：hotel-main
 */

@Slf4j
public class SyncGreenTreePicTaskThread implements Runnable{

    @Override
    public void run() {
        RedisUtil redisUtil = BeanContext.getApplicationContext().getBean(RedisUtil.class);
        GreenTreeTaskService greenTreeTaskService = BeanContext.getApplicationContext().getBean(GreenTreeTaskService.class);

        while (redisUtil.lGetListSize(RedisKeyConstant.HOTEL_MAIN_GREENTREE_PIC_LIST) > 0) {
            String hotelId = (String) redisUtil.rightPop(RedisKeyConstant.HOTEL_MAIN_GREENTREE_PIC_LIST);
            if (StringUtils.isBlank(hotelId)) {
                continue;
            }
            greenTreeTaskService.syncGreenTreePic(hotelId);
        }
    }
}
